function setRem() {
    var html = document.documentElement;
    var htmlWidth = html.getBoundingClientRect().width;
    html.style.fontSize = (htmlWidth / 414) * 100 + "px";
}

setRem();
window.onresize = setRem;